package com.lowang.test.springmvc.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;

@Component("springUtil")
public class SpringUtil implements ApplicationContextAware {
  public static ApplicationContext ctx;

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    ctx = applicationContext;
  }

  public void main(String[] args) {
    ClassPathXmlApplicationContext application =
        new ClassPathXmlApplicationContext("classpath:com/lowang/config/app-context.xml");
    application.start();
    application.destroy();
    application.close();
  }
}
